import request from '@/utils/request'
import myRequest from '@/utils/myRequest'

//员工列表查询
export function employeeList(query) {
  return request({
    url: '/system/area/employeeList',
    method: 'get',
    params: query
  })
}

//员工列表导出
export const exportEmployeeList = (params = {}) => {
  return myRequest({
    method: 'get',
    url: `/system/area/exportEmployeeList`,
    responseType: 'blob',
    params
  })
}


// 查询行政区划列表
export function listArea(query) {
  return request({
    url: '/system/area/list',
    method: 'get',
    params: query
  })
}

// 查询行政区划详细
export function getArea(areaId) {
  return request({
    url: '/system/area/' + areaId,
    method: 'get'
  })
}

/**
 * 系统设置-地区管理-查询下拉树结构
 * url:'/system/area/treeselect'
 * method:GET
 * @Header Authorization: 登录接口返回的token
 * @Query params:{}
 * @returns {*}
 */
export const getRegionAllListAPI = (params = {}) => {
  return request.get('/system/area/treeselect', {
    params
  })
}

// 查询行政区划下拉树结构
export function treeselect() {
  return request({
    url: '/system/area/treeselect',
    method: 'get'
  })
}

// 根据角色ID查询行政区划树结构
export function roleAreaTreeselect(roleId) {
  return request({
    url: '/system/area/roleAreaTreeselect/' + roleId,
    method: 'get'
  })
}

// 新增行政区划
export function addArea(data) {
  return request({
    url: '/system/area',
    method: 'post',
    data: data
  })
}

// 修改行政区划
export function updateArea(data) {

  //重新组装数据
  data.name = data.label
  /*if (!data.pid) data.pname = '中国'
  if (!data.plabel) {
    data.plabel = 'aaa'
  }*/

  return request({
    url: '/system/area/editSimple',
    method: 'put',
    data: data
  })
}

// 修改行政区划(比例)
export function updateArea2(data) {

  //重新组装数据
  data.name = data.label
  /*if (!data.pid) data.plabel = '中国'
  if (!data.plabel) {
    data.plabel = 'aaa'
  }*/
  return request({
    url: '/system/area/editProportion',
    method: 'put',
    data: data
  })
}

// 删除行政区划
export function delArea(areaId) {
  return request({
    url: '/system/area/' + areaId,
    method: 'delete'
  })
}


